package com.edt.ichannel.api.controller;


import cc.edt.iceutils2.number.IceNumberUtils;
import cc.edt.iceutils2.string.IceStringUtils;
import com.edt.ichannel.api.common.controller.BaseController;
import com.edt.ichannel.api.common.entity.ActionResult;
import com.edt.ichannel.api.service.ComputeCommissionKdService;
import com.edt.ichannel.api.service.SynDataService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/")
public class SynDataController extends BaseController {

    @Resource
    private SynDataService synDataService;

    @Resource
    private ComputeCommissionKdService computeCommissionKdService;

    @RequestMapping("syndata")
    public String synData(HttpServletRequest request) {
        String type = request.getParameter("type");
        String param = request.getParameter("param");
        String method = request.getParameter("method");
        String dataStr = request.getParameter("dataStr");
        switch (type) {
            case "synMechanismsInfo":
                synDataService.synMechanismsInfo();
                break;
            case "synHrStaff":
                synDataService.synHrStaff();
                break;
            case "synOrderIchannel":
                synDataService.synOrderIchannel(IceNumberUtils.toInt(param, 0));
                break;
            case "synOrderIchannelDay":
                synDataService.synOrderIchannelDay(IceNumberUtils.toInt(param, 0));
                break;

            case "synOrderIchannelMonth":
                synDataService.synOrderIchannelMonth(IceNumberUtils.toInt(param));
                break;

            case "synAccountCompare":
                synDataService.synAccountCompare(IceNumberUtils.toInt(param));
                break;
            case "writOrderToTempPath":
                synDataService.writOrderToTempPath(method, IceNumberUtils.toInt(param, -1), dataStr);
                break;
            case "synRedPacketOrder":
                synDataService.synRedPackageOrder(IceNumberUtils.toInt(param, -1));
                break;
            case "synRedPacketOrderResult":
                synDataService.synRedPackageOrderResult(IceNumberUtils.toInt(param, 0));
                break;
            case "computRedCount":
                synDataService.computRedpacketCount();
                break;
            case "computBonus":
                synDataService.computBonus(param);
                break;
            case "synMonthDateToKafKa":
                synDataService.synOrderIchannelMonthToKafKaFtp(param);
                break;

            case "readKafKaResFile":
                if (IceStringUtils.isNotBlank(param)) {
                    synDataService.synMonthDataFromKafka(param);
                }
                break;
            case "compareKafKaResData":
                synDataService.compareKafkaDataAndSaveError();
                break;
            case "computCommissionCK":
                synDataService.selectFirstMoneyCk();
                break;
            case "computCommissionKD":
                synDataService.selectFirstMoneyKd();
                break;
            case "moveDateToOrderCreditCk":
                synDataService.moveDataToOrderCreditCk();
                break;
            case "moveDateToOrderCreditKd":
                synDataService.moveDataToOrderCreditKd();
                break;
            case "putOutCommissionCk":
                synDataService.putOutCommissionCK();
                break;
            case "putOutCommissionKd":
                synDataService.putOutCommissionKd();
                break;
            case "synUnicomPyaReq":
                synDataService.synUnicomPyaReq();
                break;
            case "synUnicomPyaReqBatch":
                synDataService.synUnicomPyaReqBatch();
                break;
            case "synUnicomPyaReqBatchState":
                synDataService.synUnicomPyaReqBatchState();
                break;

            case "synAllExpansion":
                synDataService.synAllExpansion(null);
                break;
            case "selectFirstMoneyCkC":
                synDataService.selectFirstMoneyCkC();
                break;
            case "selectFirstMoneyKdC":
                synDataService.selectFirstMoneyKdC();
                break;
            case "selectUserIdC":
                synDataService.selectUserIdC();
                break;
            case "computCommissionBf":
                synDataService.computCommissionBf();
                break;
            case "putoutCommissionBf":
                synDataService.putoutCommissionBf();
                break;
            case "putoutCommissionMonth":
                synDataService.putoutCommissionMonth();
                break;
            case "computeCommissionMonth":
                synDataService.computeCommissionMonth();
                break;
            case "synOrderD07":
                synDataService.synOrderIchannelDayForFXQYZX(-1);
                break;
            default:

        }
        return "index";
    }

    @RequestMapping("synActivityStaff")
    @ResponseBody
    public void synData(String dateStr) {
        ActionResult result = synDataService.synActivityStaff(dateStr);
        WriterToPageByJson(result);
    }

    @RequestMapping("computByOrderCode")
    @ResponseBody
    public void synData(String method, String type, String orderCode) {
        switch (method) {
            case "selectFirstMoney":
                synDataService.selectFirstMoneyByOrderCode(orderCode, type);
                break;
            case "putOutCommission":
                synDataService.putOutCommissionByOrderCode(orderCode, type);
                break;
            case "movDataToOrderCredit":
                synDataService.moveDataToOrderCreditByOrderCode(orderCode, type);
                break;
            case "computBouns":
                synDataService.computBounsMoneyByOrderCode(orderCode);
                break;
            case "pushuserId":
                synDataService.pushUseridByOrderCode(orderCode);
                break;
            default:

        }
    }

}
